/****************************************************************************
   Copyright 2013 Stacy Doss

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
****************************************************************************/

%{
#include "sparse.tab.h"
extern int line_number;
//extern "C" void yyerror (char* s);
%}
%option noyywrap

 
%%
library                   { return LIBRARY; }

\"[^\"]*\"                { yylval.s=strdup(yytext);
                            /* printf("FROM FLEX QSTRING: %s\n", yytext); */
                            return QSTRING; } 

[0-9]+                    { yylval.i=atoi(yytext);
                            /* printf("FROM FLEX INT: %s\n", yytext); */
                            return INT; }

[0-9]+\.[0-9]+            { yylval.f=atof(yytext);
                            /* printf("FROM FLEX FLOAT: %s\n", yytext); */
                            return FLOAT; }

\@\@[_a-zA-Z0-9\.]*       { yylval.s=strdup(yytext);
                            /* printf("FROM FLEX IDENT: %s\n", yytext); */
                            return IDENT; }

[_a-zA-Z0-9\.\&\!\+\-]*   { yylval.s=strdup(yytext);
                            /* printf("FROM FLEX NAME: %s\n", yytext); */
                            return NAME; }


\(                       { /* printf("LPAREN\n"); */
                           return LPAREN; }

\)                       { /* printf("RPAREN\n"); */
                            return RPAREN; }

\{                       { /* printf("LBRACE\n"); */
                            return LBRACE; }

\}                       { /* printf("RBRACE\n"); */
                            return RBRACE; }

\:                       { /* printf("COLON\n"); */
                            return COLON; }

\;                       { /* printf("SEMI\n"); */
                            return SEMI; }

\,                       { /* printf("COMMA\n"); */
                            return COMMA; }

\\                       { }


[ \t\r]+                  /* eat up whitespace */
[\n]                      { line_number++; }

"/*""/"*([^*/]|[^*]"/"|"*"[^/])*"*"*"*/"  /* eat comments */

%%
